/*
 *  Copyright 2011 Arngrimur Bjarnason 
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
 

/**
 * 
 */
package org.arngrimur.deviationtable.view;


import org.arngrimur.deviationtable.IDegree;
import org.arngrimur.deviationtable.DisplayDegree;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.TextView;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;

/**
 * @author Arngrimur Bjarnason, arngrimurbjarnason@gmail.com
 *
 */
public abstract class DisplayString extends TextView implements  DisplayDegree {
	
	protected IDegree degree;	

/**
	 * @param context 
	 */
	public DisplayString(Context context, IDegree degree) {
		super(context);
		this.degree = degree;
		setTextViewProperties();
	}

	/**
	 * @param context
	 * @param attrs
	 */
	public DisplayString(Context context, AttributeSet attrs, IDegree degree) {
		super(context, attrs);
		this.degree = degree;
		setTextViewProperties();
	}



	/**
	 * @param context
	 * @param attrs
	 * @param defStyle
	 */
	public DisplayString(Context context, AttributeSet attrs, int defStyle, IDegree degree) {
		super(context, attrs, defStyle);
		this.degree = degree;
		setTextViewProperties();
	}
	
	/**
	 * Set properties for the super class TextView
	 */
	private void setTextViewProperties() {
		setText(this.degree.toString());
		setTextColor(ColorStateList.valueOf(Color.BLACK));
		setGravity(Gravity.CENTER);
	}

	/* (non-Javadoc)
	 * @see org.arngrimur.deviationtable.IDisplay#getDegree()
	 */
	@Override
	public IDegree getDegree() {
		return degree;
	}

	/* (non-Javadoc)
	 * @see org.arngrimur.deviationtable.IDisplay#setDegree(org.arngrimur.deviationtable.Degree)
	 */
	@Override
	public void setDegree(IDegree degree) {
		this.degree = degree;
	}
	@Override
	public String toString() {
		return this.degree.toString();
	}

	
}
